package com.colorlight.cloud.grandshow.entity.event;

import com.colorlight.cloud.gateway.api.message.constraint.schedule.ScheduleActions;
import com.colorlight.cloud.grandshow.api.GrandShowEntityEvent;
import com.colorlight.iot.proto.grandshow.event.GrandShowEvent;
import com.google.protobuf.ByteString;
import com.google.protobuf.InvalidProtocolBufferException;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.extern.slf4j.Slf4j;

/**
 * 获取设备主体信息
 */
@Data
@NoArgsConstructor
@AllArgsConstructor
@Builder
@Slf4j
public class GetMainDeviceInfo implements GrandShowEntityEvent {
    private String mainModel;

    @Override
    public ScheduleActions byteConvertObject(ByteString bytes) {
        GrandShowEvent.GetMainDeviceInfo getMainDeviceInfo = null;
        try {
            getMainDeviceInfo = GrandShowEvent.GetMainDeviceInfo.parseFrom(bytes);
        } catch (InvalidProtocolBufferException e) {
            log.error("", e);
        }
        this.setMainModel(getMainDeviceInfo.getMainModel());
        return this;
    }
}